using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DTO
{
	/// <summary> 
	///Author: nnamthach@gmail.com 
	/// <summary>
	
    public class DownloadCategoriesInfo
    {
		#region Local Variable
		public enum Field
		{
			ID,
			Name,
			NameVN,
			Rank,
			IDStatus
		}
		private Int32 _ID;
		private String _Name;
		private String _NameVN;
		private Int32 _Rank;
		private Int32 _IDStatus;
		
		public Int32 ID{	get{ return _ID;} set{_ID = value;} }
		public String Name{	get{ return _Name;} set{_Name = value;} }
		public String NameVN{	get{ return _NameVN;} set{_NameVN = value;} }
		public Int32 Rank{	get{ return _Rank;} set{_Rank = value;} }
		public Int32 IDStatus{	get{ return _IDStatus;} set{_IDStatus = value;} }
		
        #endregion LocalVariable
        
        #region Constructor
		public DownloadCategoriesInfo()
		{
			_ID = 0;
			_Name = "";
			_NameVN = "";
			_Rank = 0;
			_IDStatus = 0;
		}
		public DownloadCategoriesInfo(
		Int32 ID,
		String Name,
		String NameVN,
		Int32 Rank,
		Int32 IDStatus
		)
		{
			_ID = ID;
			_Name = Name;
			_NameVN = NameVN;
			_Rank = Rank;
			_IDStatus = IDStatus;
		}
		public DownloadCategoriesInfo(DataRow dr)
		{
			if (dr != null)
			{
				_ID = dr[Field.ID.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.ID.ToString()]);
				_Name = dr[Field.Name.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Name.ToString()]);
				_NameVN = dr[Field.NameVN.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.NameVN.ToString()]);
				_Rank = dr[Field.Rank.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.Rank.ToString()]);
				_IDStatus = dr[Field.IDStatus.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.IDStatus.ToString()]);
			}
		}
		public DownloadCategoriesInfo(DownloadCategoriesInfo objEntr)
		{			
			_ID = objEntr.ID;			
			_Name = objEntr.Name;			
			_NameVN = objEntr.NameVN;			
			_Rank = objEntr.Rank;			
			_IDStatus = objEntr.IDStatus;			
		}
        #endregion Constructor
        
        #region InitTable
		public DataTable ToDataTable()
		{
			DataTable dt = new DataTable("DownloadCategories");
			dt.Columns.AddRange(new DataColumn[] { 
				new DataColumn(Field.ID.ToString(), typeof(Int32)),
				new DataColumn(Field.Name.ToString(), typeof(String)),
				new DataColumn(Field.NameVN.ToString(), typeof(String)),
				new DataColumn(Field.Rank.ToString(), typeof(Int32)),
				new DataColumn(Field.IDStatus.ToString(), typeof(Int32))
			});
			return dt;
		}
		public DataRow ToDataRow(DataTable dt)
		{
			DataRow row = dt.NewRow();
			row[Field.ID.ToString()] = _ID;
			row[Field.Name.ToString()] = _Name;
			row[Field.NameVN.ToString()] = _NameVN;
			row[Field.Rank.ToString()] = _Rank;
			row[Field.IDStatus.ToString()] = _IDStatus;
			return row;
		}
        #endregion InitTable
    }
}
